package com.huangmb.anymark.app.model;

import android.os.Parcel;
import android.os.Parcelable;
import com.amap.api.maps.model.LatLng;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.core.PoiItem;
import com.amap.api.services.poisearch.PoiSearch;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/4/21 16:35
 */
public class Position implements Parcelable {
    public static final PositionCreator CREATOR = new PositionCreator();

    private double latitude;//纬度
    private double longitude;//经度

    private String address;//位置描述
    public Position(){

    }
    public Position(double latitude,double longitude) {
        this(latitude,longitude, null);
    }

    public Position(double latitude,double longitude, String address) {
        this.latitude = latitude;
        this.longitude = longitude;
        this.address = address;
    }

    public LatLng toAmapLatLng(){
        return new LatLng(latitude,longitude);
    }
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeDouble(latitude);
        dest.writeDouble(longitude);
        dest.writeString(address);

    }

    private static class PositionCreator implements Parcelable.Creator<Position> {

        @Override
        public Position createFromParcel(Parcel source) {
            double latitude = source.readDouble();
            double longitude = source.readDouble();
            String address = source.readString();
            return new Position(latitude,longitude, address);
        }

        @Override
        public Position[] newArray(int size) {
            return new Position[size];
        }
    }
}
